package com.py.behavior.servicer.impl;

import com.py.apis.article.IArticleClient;
import com.py.behavior.servicer.BhUnLikesService;
import com.py.model.behavior.dtos.UnLikesBehaviorDto;
import com.py.model.common.dtos.ResponseResult;
import com.py.model.common.enums.AppHttpCodeEnum;
import com.py.utils.common.ApUserThreadLocalUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName BhUnLikesServiceImpl
 * @Description TODO
 * @Author AXing
 * @Date 2022/11/17 0:42
 * @Version 1.0
 */
@Service
@Slf4j
public class BhUnLikesServiceImpl implements BhUnLikesService {

    @Autowired
    private IArticleClient articleClient;
    /**
     * 文章不喜欢
     * @param dto
     * @return
     */
    @Override
    public ResponseResult unLikesBehavior(UnLikesBehaviorDto dto) {
        //当前用户id
        Integer userId = ApUserThreadLocalUtil.get().getId();
        dto.setUserId(userId);
        log.info("UnlikesBehavior--->{}", dto);
        if (dto == null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        //调用接口
        Integer integer = articleClient.articleUnLike(dto);
        return ResponseResult.okResult(integer);
    }
}
